package com.tongtailian.www.stir.adapter;

import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tongtailian.www.stir.R;
import com.tongtailian.www.stir.bean.ConfigBean;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * Created by liuml on 2020/9/6 16:48
 */
public class ConfigAdapter extends BaseQuickAdapter<ConfigBean, BaseViewHolder> {
    private boolean isDef = false;
    public ConfigAdapter(int layoutResId, @Nullable List<ConfigBean> data, boolean isDef) {
        super(layoutResId, data);
        this.isDef = isDef;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, ConfigBean item) {
        helper.setText(R.id.bt_item_name, item.getName())
                .setText(R.id.bt_item_look, item.getLook());

        TextView bt_item_look = helper.getView(R.id.bt_item_look);
        if(isDef)
            bt_item_look.setVisibility(View.GONE);
        else
            bt_item_look.setVisibility(View.VISIBLE);

        helper.addOnClickListener(R.id.bt_item_name);
        helper.addOnClickListener(R.id.bt_item_look);
        if (item.isSelect()) {
            helper.setBackgroundRes(R.id.bt_item_name, R.mipmap.run_type_name_select_png);
            helper.setTextColor(R.id.bt_item_name, Color.parseColor("#ffffff"));
        }else {
            helper.setTextColor(R.id.bt_item_name, Color.parseColor("#000000"));
            helper.setBackgroundRes(R.id.bt_item_name, R.mipmap.run_type_name_none_png);
        }
    }
}